package ui.activity.order.biz;

import Bean.OrderBean;
import base.BaseBiz;
import base.BaseResp;
import coom.BaseSubscribe;
import coom.RetrofitHelp;
import okhttp3.RequestBody;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by chenjian on 19/2/26.
 * 1
 */

public class OrderBiz extends BaseBiz {


    /**
     * 获取订单列表
     */
    public void getOrder(RequestBody requestBody, final Callback<OrderBean.DataBean> callback) {
        com.add(RetrofitHelp.getSecretApi().getOrderType(requestBody)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe<BaseResp<OrderBean.DataBean>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((OrderBean.DataBean) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((OrderBean.DataBean) obj);
                    }
                })
        );
    }

    /**
     * 取消订单
     */
    public void cancleOrder(RequestBody requestBody, final Callback<Object> callback) {
        com.add(RetrofitHelp.getSecretApi().cancelOrder(requestBody)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe<BaseResp<Object>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((Object) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((Object) obj);
                    }
                })
        );
    }

    /**
     * 确认收货
     */
    public void confirmOrder(RequestBody requestBody, final Callback<Object> callback) {
        com.add(RetrofitHelp.getSecretApi().confirmOrder(requestBody)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe<BaseResp<Object>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((Object) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((Object) obj);
                    }
                })
        );
    }


}
